<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta name="author" content="yinq">
<title>首页 - hean校风云系统</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" th:href="@{css/materialdesignicons.min.css}">
<link rel="stylesheet" type="text/css" th:href="@{css/bootstrap.min.css}">
<link rel="stylesheet" type="text/css" th:href="@{css/animate.min.css}">
<link rel="stylesheet" type="text/css" th:href="@{css/style.min.css}">
  <link rel="stylesheet" th:href="@{layui-v2.5.6/layui/css/layui.css}" media="all" />

</head>
<body>
<div th:include="comm/comm.html"></div>
    <!--页面主要内容-->
<!--页面主要内容-->
<main class="lyear-layout-content">

  <div class="container-fluid p-t-15">

    <div class="row">
      <div class="col-lg-12">
        <div class="card">
          <div class="card-header"><div class="card-title">写入绩效</div></div>
          <div class="card-body">

            <form class="guide-box">
              <ul class="nav nav-step">
                <li class="nav-item">
                  <span>步骤一</span>
                  <a class="nav-link active" data-toggle="tab" href="#step-1"></a>
                </li>

                <li class="nav-item">
                  <span>步骤二</span>
                  <a class="nav-link" data-toggle="tab" href="#step-2"></a>
                </li>

                <li class="nav-item">
                  <span>步骤三</span>
                  <a class="nav-link" data-toggle="tab" href="#step-3"></a>
                </li>

                <li class="nav-item">
                  <span>步骤四</span>
                  <a class="nav-link" data-toggle="tab" href="#step-4"></a>
                </li>
              </ul>
              <!--对应内容-->
              <div class="nav-step-content">
                <div class="nav-step-pane d-none active" id="step-1"  data-provide="validation">
                  <div class="form-group">
                    <label>教师姓名</label>
                    <select name="tname" class="form-control" type="text" id="username" required >
                    </select>
                  </div>
                </div>

                <div class="nav-step-pane d-none" id="step-2" data-provide="validation">
                  <div class="form-group">
                    <label>考核月份</label>
                    <input class="form-control" name="month" type="text" id="month" required />
                  </div>
                </div>

                <div class="nav-step-pane d-none" id="step-3" data-provide="validation">
                  <div class="form-group">
                    <label>考核成绩</label>
                    <input class="form-control" name="achievements" type="text" id="achievements" required />
                  </div>
                </div>

                <div class="nav-step-pane d-none" id="step-4">
                  <div class="form-group">
                    <label>备注</label>
                    <input class="form-control" type="text" id="remark" />
                  </div>
                </div>
              </div>
              <!--End 对应内容-->
              <hr>
              <div class="d-flex justify-content-between">
                <button class="btn btn-secondary disabled" data-wizard="prev" type="button">上一步</button>
                <button class="btn btn-secondary" data-wizard="next" type="button">下一步</button>
                <button class="btn btn-primary d-none" data-wizard="finish" onclick="insert()">完成</button>
              </div>
            </form>

          </div>
        </div>
      </div>

    </div>

  </div>
  <div class="demoTable" style="margin-top: 30px">
    <div class="layui-inline">
      <input class="layui-input" name="keyword" placeholder="请输入月份" value="8" id="month1" autocomplete="off">
    </div>
    <button class="layui-btn" onclick="f()">搜索</button>
  </div>

  <div id="container" style="height: 100%;margin-top: 20px;"></div>


</main>

<script type="text/javascript" th:src="@{js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{js/perfect-scrollbar.min.js}"></script>
<script type="text/javascript" th:src="@{js/jquery.cookie.min.js}"></script>
<script type="text/javascript" th:src="@{js/main.min.js}"></script>
<script type="text/javascript" th:src="@{js/jquery.bootstrap.wizard.min.js}"></script>
<script type="text/javascript" th:src="@{/js/echarts.js}"></script>
<script type="text/javascript">
  $(document).ready(function() {
    var guideObj = $('.guide-box');
    var nav_item = guideObj.find('.nav-item');
    var tab_pane = guideObj.find('.nav-step-pane');

    guideObj.bootstrapWizard({
      'tabClass': 'nav-step',
      'nextSelector': '[data-wizard="next"]',
      'previousSelector': '[data-wizard="prev"]',
      'finishSelector': '[data-wizard="finish"]',
      'onTabClick': function(e, t, i) {
        // data-navigateable='true'允许用户直接点击步骤项，false则只能通过按钮
        if ( !$('.guide-box').is('[data-navigateable="true"]') ) {
          return false;
        }
      },
      'onTabShow': function(e, t, i) {
        t.children(":gt(" + i + ").complete").removeClass("complete");
        t.children(":lt(" + i + "):not(.complete)").addClass("complete");
      },
      'onNext': function(tab, navigation, index){
        var current_index = guideObj.bootstrapWizard('currentIndex');
        var curr_tab      = tab_pane.eq(current_index);

        var validator_selector = '[data-provide="validation"]';
        var validator = curr_tab.find(validator_selector).addBack(validator_selector);
        if (validator.length) {
          var forms = validator.find('input, select, textarea');
          var validation = true;
          forms.each(function() {
            if (this.checkValidity() === false) {
              guideObj.addClass('was-validated');
              validation = false;
            } else {
              guideObj.removeClass('was-validated');
            }
          });
          if (!validation) {
            guideObj.addClass('was-validated');
            return false;
          }
        }
      },
      'onPrevious': function(){
      },
      'onFinish': function(e, t, i) {
        var nav = nav_item.eq(i);

        nav.addClass('complete').find('a.nav-link').removeClass('active');
        return true; // 这里为了演示效果，阻止其继续
      }
    });
  });

  function insert(){
    var tname = $("#username").val();
    var month = $("#month").val();
    var achievements = $("#achievements").val();
    $.ajaxSettings.async=false;
    $.ajax({
      url:"insertAchi",
      type:"post",
      data:{"tname":tname,"month":month,"achievements":achievements},
      success:function (data) {
         alert(data)
      }
    })
  }

  $(function tname() {
        $.ajax({
          url: "teacherall?page=1&limit=20",
          type: "post",
          success: function (data) {
            var list = data.data;
            $.each(list, function (index, item) {
              var option = $("<option></option>").append(item.tname);
              $("#username").append(option);
            })


          }

        })

  })


  $(function f() {
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};
    var option;
    var month = $("#month1").val();
    // 获取统计内容
    $.post("findAllAch?month="+8,function (r) {
      if (r==""){
        alert("暂无此月份数据！")
      }
      var x_data = [];
      for (let i = 0; i < r.length; i++) {
        x_data.push(r[i].tname)
      }
      var y_data = [];
      for (let i = 0; i < r.length; i++) {
        y_data.push(r[i].achievements)
      }

      option = {
        title: {
          text: '公司'+month+'月份绩效',
          subtext: '真实有效',
          left: 'center'
        },
        xAxis: {
          type: 'category',
          data: x_data
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: y_data,
            type: 'bar',
            itemStyle: {
              normal: {
                label: {
                  show: true, //开启显示
                  position: 'top', //在上方显示
                  textStyle: { //数值样式
                    color: 'black',
                    fontSize: 16
                  }
                }
              }
            },
          }
        ]
      };
      if (option && typeof option === 'object') {
        myChart.setOption(option);
      }
    })

  })

</script>
</body>
</html>